<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<link href="images/skin.css" rel="stylesheet" type="text/css" />
<link href="images/fox.css" rel="stylesheet" type="text/css" />
<script type='text/javascript' src='/scm/dwr/interface/Jpurchase.js'></script>
<script type='text/javascript' src='/scm/dwr/engine.js'></script>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<script type='text/javascript' src='/scm/dwr/util.js'></script>
<script type="text/javascript" src="../js/jquery.js"></script>
<script type="text/javascript" language="JavaScript">

  
/*$(function(){  //文档加载 
$(".tbody tr").hover( 
  function(){ 
    $(this).addClass("hover");    //鼠标经过添加hover样式 
  }, 
  function(){ 
    $(this).removeClass("hover");   //鼠标离开移除hover样式 
  }

); 
}); */
	function checkcodel(year){

		Jpurchase.queryyearpurchases(year,checkokcodel);
		
	}
	function checkokcodel(date){ 

		var selects=document.getElementById("select");

			selects.length=0;
		if(date==null){
			
			selects.add(new Option("空","1"));
		}else{
			for(var i=0;i<date.length;i++){
			
				var yearpurchase=date[i]; 
				selects.add(new Option(yearpurchase.modeldictionary.brand.brandName+yearpurchase.modeldictionary.modelCode+"("+yearpurchase.modeldictionary.modelFeature+")",yearpurchase.yearPurchaseId));
			}
		
		}
	}
	
	
	var Id=0;
	var yid=0
	function updatecount(id,yearid){
		Id=id;
		yid=yearid;
		var currens=document.getElementById(Id);
		currens.cells[7].innerHTML="<a href='javascript:updatecount1()' style='color:#000099'>保存</a>";
		var count=currens.cells[5].innerHTML;
		currens.cells[5].innerHTML="<input id='cs' value='"+count+"'/>";
		
	}
	function updatecount1(){
		
		var cout=document.getElementById("cs").value;
		var geshi=/^[0-9]*[1-9][0-9]*$/;
		if(!geshi.test(cout)){
			alert("请输入正确的数字格式");
		}else{
			Jpurchase.updatemonths(Id,yid,cout,update);
		}
		
		
		
	}
	function update(){
		
	var cout=document.getElementById("cs").value;

	var currens=document.getElementById(Id);
	currens.cells[7].innerHTML="<a href='javascript:updatecount("+Id+")' style='color:#000099'>修改</a>";
	currens.cells[5].innerHTML=cout;
	Id=0;
	
	
	}
</script> 
<style type="text/css"> 
.hover{background-color:#CACACA;}  /*这里是鼠标经过时的颜色*/ 

</style>
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	background-color: #EEF2FB;
}
-->
</style>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="17" valign="top" background="images/mail_leftbg.gif"><img src="images/left-top-right.gif" width="17" height="29" /></td>
    <td valign="top" background="images/content-bg.gif"><table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="left_topbg" id="table2">
      <tr>
        <td height="31"><div class="titlebt">采购管理</div></td>
      </tr>
    </table></td>
    <td width="16" valign="top" background="images/mail_rightbg.gif"><img src="images/nav-right-bg.gif" width="16" height="29" /></td>
  </tr>
  <tr>
    <td valign="middle" background="images/mail_leftbg.gif">&nbsp;</td>
    <td valign="top" bgcolor="#F7F8F9">
			<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" class="line_table">
		<tr>
		<td width="20">
		<img src="../images/icon-login-seaver.gif" width="16" height="16" />
		</td>
		<td>
		当前位置：采购管理>>全年采购计划分解(decompositionProcurementPlanSelect.html)
		</td>

	</tr>
	</table>
	<form action="purchaseaction!queryyearandbrand.action" method="post">
	<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" class="line_table">
		<tr>
		
		<td width="10%" align="center" height="30"><span class="left_bt2">请选择年份</span></td>
		<td width="9%">
		
		<s:if test="#qyearlist.isEmpty()">
		<select>
			<option>无</option>
		</select>
		</s:if>
		<s:else>
		<select name="projectname" class="sec2" style="width:100px" onchange="checkcodel(this.value)">
		<option value="0" selected="selected">请选择</option>
		<s:iterator value="qyearlist" var="month" status="st">
	  	<option value="<s:property value="#month"/>"><s:property value="#month"/></option>
	  	</s:iterator>
	  </select>
	  </s:else>
	  </td>
		<td width="7%" align="left"><span class="left_bt2">请选择车型</span></td>
		<td width="22%">
		<select name="select" id="select" class="sec2" style="width:250px" >
		  
        </select></td>
		  
		  <td width="52%"><input type="submit" class="Submit" value="查看" style="width:100px"/></td>
	</tr>
	
	</table>
	</form>
	<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" class="line_table">
	<thead class="thead">
    	<tr>
		<th>序号</th>
		<th>品牌</th>
		<th>车辆编码</th>
		<th>年份</th>	
		<th>月份</th>	
		<th>计划数量</th>	
		<th>已采购</th>	
		<th>操作</th>
		</tr>
		</thead>
		<tbody class="tbody">
		<s:if test="!monthlist.isEmpty()">
		<s:iterator value="monthlist" var="mon" status="st">
		 <tr id="<s:property value="#mon.monthPurchaseId"/>">
		<td><s:property value="#st.index"/></td>
		<td><s:property value="#mon.yearpurchase.modeldictionary.brand.brandName"/></td>
		<td><s:property value="#mon.yearpurchase.modeldictionary.modelCode"/></td>
		<td><s:property value="#mon.yearpurchase.year"/></td>
		<td><s:property value="#mon.month"/></td>	
		<td><s:property value="#mon.planPurchaseCount"/></td>	
		<td><a style="color:#CC0000"><s:property value="#mon.purchaseCount"/></a></td>	
		<td><a href="javascript:updatecount(${mon.monthPurchaseId},${mon.yearpurchase.yearPurchaseId})" style="color:#000099">修改</a></td>
		</tr>
		</s:iterator>
		</s:if>
		<s:else>		
			<tr align="center"><td colspan="8"><font color="red">对不起，没有您要查询的信息。</font></td></tr>
		</s:else>
		</tbody>						
    </table>
	</td>
    <td background="images/mail_rightbg.gif">&nbsp;</td>
  </tr>
  <tr>
    <td valign="bottom" background="images/mail_leftbg.gif"><img src="images/buttom_left2.gif" width="17" height="17" /></td>
    <td background="images/buttom_bgs.gif"><img src="images/buttom_bgs.gif" width="17" height="17"></td>
    <td valign="bottom" background="images/mail_rightbg.gif"><img src="images/buttom_right2.gif" width="16" height="17" /></td>
  </tr>
</table>
页面要求：<br />
1.年份下拉框是根据“全年采购计划表”中的年份来进行显示。如果系统还没有创建过全年采购计划，那么请选择年份下拉框中数据有一条为“无”。<br />
2.根据选择的年份来确定车型，这要使用AJAX级联互动的方式实现，要完成根据选择年份的查询出本年份内已经分解过的车型信息并显示到请选择车型下拉框中，<br/>
如果查询出来的信息为空那么在“请选择车型下拉框”中显示一条记录为空。<br/>
3.点击修改后，计划数量变为文本框并且将原先的数字默认输入到文本框内，同时修改变为保存，当点击保存后需要做非空和有效性验证。
</body>
</html>